package com.ldj.taglib;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.tagext.TagSupport;

import com.ldj.hibernate.DataDictionary;
import com.ldj.hibernate.DataDictionaryDAO;

public class QueryTag extends TagSupport{

	private static final long serialVersionUID = 1L;

	private String value;

	public int doStartTag() throws JspException{
		try{
			DataDictionaryDAO dao = new DataDictionaryDAO(null, null);
			StringBuffer stringbuffer = new StringBuffer("");
			if(value != null){
				DataDictionary d = dao.findFromCode(value);
				if(d != null){
					stringbuffer.append(d.getDataDictionaryName());
				}
			}
			pageContext.getOut().write(stringbuffer.toString());
		}catch (IOException ex){
			throw new JspTagException("acmstag: " + ex.getMessage());
		} catch(Exception ex){
			throw new JspTagException("acmstag: " + ex.getMessage());
		}
		return SKIP_BODY;
	}

	public int doEndTag(){
		return EVAL_PAGE;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}
}
